// To parse this JSON data, do
//
//     final GLMealModel = GLMealModelFromJson(jsonString);

// ignore_for_file: non_constant_identifier_names, prefer_typing_uninitialized_variables

import 'dart:convert';

import 'dart:core';

GLMealModel GLMealModelFromJson(String str) =>
    GLMealModel.fromJson(json.decode(str));

String GLMealModelToJson(GLMealModel data) => json.encode(data.toJson());

List<String> complex = ['简单', '中等', '复杂'];

class GLMealModel {
  String id;
  List<String> categories;
  String title;
  int affordability;
  int complexity;
  String? complexStr;
  String imageUrl;
  int duration;
  List<String> ingredients;
  List<String> steps;
  bool isGlutenFree;
  bool isVegan;
  bool isVegetarian;
  bool isLactoseFree;

  GLMealModel({
    required this.id,
    required this.categories,
    required this.title,
    required this.affordability,
    required this.complexity,
    this.complexStr,
    required this.imageUrl,
    required this.duration,
    required this.ingredients,
    required this.steps,
    required this.isGlutenFree,
    required this.isVegan,
    required this.isVegetarian,
    required this.isLactoseFree,
  });



  factory GLMealModel.fromJson(Map<String, dynamic> json) => GLMealModel(
        id: json["id"],
        categories: List<String>.from(json["categories"].map((x) => x)),
        title: json["title"],
        affordability: json["affordability"],
        complexity: json["complexity"],
        complexStr: complex[json["complexity"]],
        imageUrl: json["imageUrl"],
        duration: json["duration"],
        ingredients: List<String>.from(json["ingredients"].map((x) => x)),
        steps: List<String>.from(json["steps"].map((x) => x)),
        isGlutenFree: json["isGlutenFree"],
        isVegan: json["isVegan"],
        isVegetarian: json["isVegetarian"],
        isLactoseFree: json["isLactoseFree"],
      );

  Map<String, dynamic> toJson() => {
      "id": id,
      "categories": List<dynamic>.from(categories.map((x) => x)),
      "title": title,
      "affordability": affordability,
      "complexity": complexity,
      "imageUrl": imageUrl,
      "duration": duration,
      "ingredients": List<dynamic>.from(ingredients.map((x) => x)),
      "steps": List<dynamic>.from(steps.map((x) => x)),
      "isGlutenFree": isGlutenFree,
      "isVegan": isVegan,
      "isVegetarian": isVegetarian,
      "isLactoseFree": isLactoseFree,
    };
}
